﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>SmartX Wallet</title>

    <!-- Bootstrap -->
    <link href="bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="js/mystyle.css" type="text/css" rel="stylesheet">

    <!--自定义样式
    <!--<style>
        .jumbotron {
            background: url(images/model.png);
        }
    </style>
     -->

    <!--ModalTransfer-->
    <style>
        .modal.fade.in {
            top: 15%;
        }

        fieldset {
            background-color: #f1f1f1;
            border: none;
            border-radius: 2px;
            margin-bottom: 12px;
            overflow: hidden;
            padding: 0 .625em;
        }

        label {
            cursor: pointer;
            display: inline-block;
            padding: 3px 6px;
            text-align: left;
            width: 80px;
            vertical-align: top;
        }

        input {
            font-size: inherit;
            width: 300px;
        }
    </style>

</head>
<body>
    <script src="bootstrap/jquery.min.js"></script>
    <script src="bootstrap/bootstrap.min.js"></script>
    <!--<script type="text/javascript" src="js/crypto/encrypt/base/basex.js"></script>
    <script type="text/javascript" src="js/crypto/encrypt/base/base58.js"></script>
    <script type="text/javascript" src="js/crypto/encrypt/ed25519/nacl-fast.js"></script>
    <script type="text/javascript" src="js/crypto/utils/encrpt-ed25519.js"></script>-->

    <script type="text/javascript" src="crypto-master/js/encrypt/base/basex.js"></script>
    <script type="text/javascript" src="crypto-master/js/encrypt/base/base58.js"></script>
    <script type="text/javascript" src="crypto-master/js/encrypt/ed25519/nacl-fast.js"></script>
    <script type="text/javascript" src="crypto-master/js/utils/encrypt-ed25519-2.js"></script>

    <script src='js/bignumber.min.js'></script>
    <script type="text/javascript" src="js/crypto-js.js"></script>
    <script src="js/aes256.min.js"></script>
    <script src='js/forge-sha256.min.js'></script>
    <script src='js/hashes.js'></script>
    <script src='js/wallet.js'></script>
    <script src='js/helper.js'></script>
    <script src='js/Login.js'></script>
    <script type="text/javascript" src="js/qrcode.min.js"></script>
    <script src="js/reqrcode.js"></script>

    <div class="container">

        <div class="jumbotron">
            <h1>SmartX</h1>
            <button type="button" class="btn btn-primary" onclick="liOnShowQRCode()">收款</button>
            <button type="button" class="btn btn-info" onclick="liOnScanQRCode()">扫码支付</button>
            <button type="button" class="btn btn-success" data-toggle="modal" data-target="#ModalTransfer">转账</button>
            <button type="button" class="btn btn-warning" id="btnCopyToClip" title="" onclick='copyToClipBoard()'
                    data-container="body" data-toggle="popover" data-placement="bottom"
                    data-content="地址已复制到剪切板">
                复制地址
            </button>
            <button type="button" class="btn btn-info" data-toggle="modal" data-target="#ModalLock">发起锁仓</button>
            &nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-danger" onclick="OnClear()">清空交易</button>

        </div>

        <h3 id="address" style='text-align:center;'>...</h3>
        <h6> </h6>

        <div style="width:100%;height:100%;overflow-x:auto;">
            <table class="table table-hover" id="waittable">
                <caption id="caption_mytable111">
                    处理列表:
                </caption>
                <thead id="thead_mytable111">
                    <tr>
                        <th>hash</th>
                        <th style='text-align:right;'>state</th>
                    </tr>
                </thead>
            </table>
        </div>

        <div style="width:100%;height:100%;overflow-x:auto;">
            <table class="table table-hover" id="mytable">
                <caption id="caption_mytable111">
                    <div class="col-lg-6">
                        账户:
                        <button type="button" class="btn  btn-default" onclick='liOnclickUp()'> 上 一 页</button>
                        <button type="button" class="btn  btn-default" onclick='liOnclickDown()'> 下 一 页</button>
                    </div>
                    <div class="col-lg-6">
                        <div class="input-group">
                            <input type="text" id="searchText" class="form-control">
                            <span class="input-group-btn">
                                <button class="btn btn-default" type="button" onclick='liOnSearch("searchText")'>Search!</button>
                            </span>
                        </div>
                        <h4></h4>
                    </div>

                </caption>
                <thead id="thead_mytable111">
                    <tr>
                        <th>hash</th>
                        <th style='text-align:right;'>state</th>
                    </tr>
                </thead>
            </table>
        </div>

    </div>

    <footer class="navbar-fixed-bottom ">
        <center>
            <div style="width:50%;height:100%;overflow-x:auto;">
                <table class="table table-hover" id="statusbar" style='background:#ffffff'>
                </table>
            </div>
        </center>
        <div class="row nav_box navbar-inverse">
            <div class="qx_1"><a href="index.html"><h3 class="text-primary">钱包</h3></a></div>
            <div class="qx_1"><a href="browser.html"><h3 class="text-success">区块</h3></a></div>
            <div class="qx_1"><a href="rules.html"><h3 class="text-danger">节点</h3></a></div>
            <div class="qx_1"><a href="setting.html"><h3 class="text-warning">设置</h3></a></div>
        </div>
    </footer>

    <div class="modal fade" id="ModalTransfer" tabindex="-1" role="dialog" aria-labelledby="ModalTransferLabel" aria-hidden="true" onload="onTransferLoad()">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×
                    </button>
                    <h5 class="modal-title" id="myModalLabel">
                        正在申请交易
                    </h5>
                </div>

                <fieldset>
                    <p> </p>
                    <p>
                        <label for="title">转出地址:</label>
                        <input type="text" id="input_addressIn" name="addressIn" align="left" disabled="disabled">
                    </p>
                    <p>
                        <label for="title">转账金额:</label>
                        <input type="text" id="input_amount" name="amount" align="left">
                        <label for="title" id="tokenname"></label>
                    </p>
                    <p>
                        <label for="username">转入地址:</label>
                        <input type="text" id="input_addressOut" name="addressOut" align="left">
                    </p>
                    <p>
                        <label for="username">备注:</label>
                        <input type="text" id="input_remarks" name="remarks" align="left">
                    </p>
                    <p>
                        <label for="username">nonce:</label>
                        <input type="text" id="input_nonce" name="nonce" align="left">
                    </p>
                    <p>
                        <label for="username">矿工费:</label>
                        <input type="text" id="gas" name="gas" align="left" value="0.002" disabled="disabled">
                    </p>
                </fieldset>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        取消
                    </button>
                    <button type="button" class="btn btn-primary" onclick="onTransferSubmit('ModalTransfer')">
                        提交
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="ModalQRCode" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="ModalQRCodeLabel" aria-hidden="true" style="top:10%">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        QRCode
                    </h4>
                </div>
                <h4></h4>
                <div id="qrcode" style="width:300px; height:300px; margin-top:15px; margin: 0 auto;"></div>
                <h4></h4>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" onclick="liOnModalQRCodeLeave()">
                        离开
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="ModalScanQRCode" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="ModalScanQRCodeLabel" aria-hidden="true" style="top:10%">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        扫码支付
                    </h4>
                </div>
                <h4></h4>
                <label id="photo">照相机<input type="file" id='photo_image1' accept="image/*" capture='camera' onchange="OnScanQRCodeChange('photo_image1')"></label>

                <fieldset>
                    <p>
                        <label for="title">转出地址:</label>
                        <input type="text" id="scan_addressIn" align="left" disabled="disabled">
                    </p>
                </fieldset>
                <fieldset>
                    <p>
                        <label for="title">转入地址:</label>
                        <input type="text" id="scan_addressOut" align="left" disabled="disabled">
                        <input type="file" id="photo_image2" onchange="OnScanQRCodeChange('photo_image2')">
                    </p>
                </fieldset>
                <fieldset>
                    <p>
                        <label for="title">转账金额:</label>
                        <input type="text" id="scan_amount" align="left">
                    </p>
                </fieldset>
                <input type="text" id="scan_nonce" align="left" style="display:none">
                <input type="text" id="scan_remarks" align="left">

                <h4></h4>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" onclick="OnScanQRCodeSubmit('ModalScanQRCode')">
                        提交
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div class="modal fade" id="ModalLock" tabindex="-1" role="dialog" aria-labelledby="ModalTransferLabel" aria-hidden="true" onload="onTransferLoad()">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        ×
                    </button>
                    <h5 class="modal-title" id="myModalLabel">
                        正在申请交易
                    </h5>
                </div>

                <fieldset>
                    <p> </p>
                    <p>
                        <label for="title">转出地址:</label>
                        <input type="text" id="input_addressIn" name="addressIn" align="left" disabled="disabled">
                    </p>
                    <p>
                        <label for="title">转账金额:</label>
                        <input type="text" id="input_amount" name="amount" align="left">
                        <label for="title" id="tokenname"></label>
                    </p>
                    <p>
                        <label for="username">转入地址:</label>
                        <input type="text" id="input_addressOut" name="addressOut" align="left">
                    </p>
                    <p>
                        <label for="username">锁仓时间:</label>
                        <input type="text" id="input_LockTime" name="lockTime" align="left">
                        <label for="username" id="LockTimeUnit">小时数</label>
                    </p>
                    <p>
                        <label for="username">锁仓名称:</label>
                        <input type="text" id="input_LockName" name="lockName" align="left">
                    </p>
                    <p>
                        <label for="username">nonce:</label>
                        <input type="text" id="input_nonce" name="nonce" align="left">
                    </p>
                    <p>
                        <label for="username">矿工费:</label>
                        <input type="text" id="gas" name="gas" align="left" value="0.002" disabled="disabled">
                    </p>
                </fieldset>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        取消
                    </button>
                    <button type="button" class="btn btn-primary" onclick="onLockSubmit('ModalLock')">
                        提交
                    </button>
                </div>
            </div>
        </div>
    </div>

    <script>
        //setTimeout(function () { window.location.href = window.location.href }, 60000); // 1分钟刷新

        if (Login.LoadPassword() == null)
            window.location.href = "index.html";

        function liOnSearch(e) {
            var text = $('#' + e).val();

            if (text != "") {
                Helper.ShowTransfer(text)
            }
        }

        function onTransferLoad(e) {
            //alert(e.id);
        };

        function OnClear(e) {
            Helper.ClearTransferWait(addressCur + tokenAddress);
            window.location.href = window.location.href;
        }

        $(function () {
            $("[data-toggle='popover']").popover();
        });

        // 地址栏参数
        function getQueryVariable(variable, search) {
            if (search == null)
                search = window.location.search;
            var query = search.substring(1);
            var vars = query.split("&");
            for (var i = 0; i < vars.length; i++) {
                var pair = vars[i].split("=");
                if (pair[0] == variable) { return pair[1]; }
            }
            return (false);
        }

        var colorlist = ["list-group-item-success", "", "list-group-item-info", "", "list-group-item-warning", "", "list-group-item-danger", ""];
        var platform = Helper.checkPlatform();
        var colorindex = 1;

        var addressCur = getQueryVariable("address");
        var tokenAddress = getQueryVariable("token");
        var symbol = getQueryVariable("symbol");
        var amountCur = 0;
        var nonceCur = 0;
        // show address
        var element = document.getElementById("address");
        element.innerHTML = " 余额: " + amountCur;
        var locktime = Date.parse(new Date()) / 1000; // 初始化时间戳

        $(function () {
            $('#ModalTransfer').on('show.bs.modal', function () {
                //var element = document.getElementById("myModalLabel");
                //element.innerHTML = "转出地址: " + addressCur;
                locktime = Date.parse(new Date()) / 1000; // 每次弹出窗口是设置时间戳， 防止多次点击
                $("#ModalTransfer #input_addressIn").val(addressCur);
                $('#ModalTransfer #input_nonce').val(nonceCur);
                $('#ModalTransfer #tokenname')[0].innerHTML = symbol;
            })

            $('#ModalLock').on('show.bs.modal', function () {
                //var element = document.getElementById("myModalLabel");
                //element.innerHTML = "转出地址: " + addressCur;
                locktime = Date.parse(new Date()) / 1000; // 每次弹出窗口是设置时间戳， 防止多次点击
                $("#ModalLock #input_addressIn").val(addressCur);
                $('#ModalLock #input_nonce').val(nonceCur);
                $('#ModalLock #tokenname')[0].innerHTML = symbol;
            })

        });

        // 复制到剪切板
        var hide_popover_timer = null;
        function copyToClipBoard() {
            var aux = document.createElement("input");
            aux.setAttribute("value", addressCur);
            document.body.appendChild(aux);

            if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {//区分iPhone设备
                window.getSelection().removeAllRanges();//这段代码必须放在前面否则无效
                var range = document.createRange();
                // 选中需要复制的节点
                range.selectNode(aux);
                // 执行选中元素
                window.getSelection().addRange(range);
                // 执行 copy 操作
                var successful = document.execCommand('copy');
                // 移除选中的元素
                window.getSelection().removeAllRanges();
            } else {
                aux.select(); // 选择对象
                document.execCommand("Copy"); // 执行浏览器复制命令
            }
            document.body.removeChild(aux);


            $("[data-toggle='popover']").popover();
            clearTimeout(hide_popover_timer);
            hide_popover_timer = setTimeout("hide_popover()", 3000);
        };

        function hide_popover() {
            var popover = document.getElementsByClassName("popover fade bottom in");
            if (popover.length >= 1)
                document.getElementById("btnCopyToClip").click();
        }

        function onTransferSubmit(e) {
            if (tokenAddress != null && tokenAddress != "") {
                var amount = new BigNumber((new BigNumber($('#ModalTransfer #input_amount').val())).toFixed(8, BigNumber.ROUND_DOWN)); // 截断小数点后8位，并且去掉多余的0
                var addressOut = tokenAddress;
                var data = "transfer(\"" + $('#ModalTransfer #input_addressOut').val() + "\",\"" + amount.toString() + "\")";
                var nonce = parseInt($('#ModalTransfer #input_nonce').val());
                var remarks = $('#ModalTransfer #input_remarks').val();
                if (CheckTransfer(amount, addressOut, nonce, "", remarks)) {
                    var hash = Helper.SendTransferSubmit(e, "contract", "", addressOut, data, "", nonce, remarks);
                    Helper.Statusbar("statusbar", hash, "", "合约交易: " + $('#ModalTransfer #input_addressOut').val() + " 转出: " + Helper.Fix(amount), 1, nonceCur);
                    Helper.MessageBox('交易已提交');
                }
            }
            else {
                var amount = new BigNumber((new BigNumber($('#ModalTransfer #input_amount').val())).toFixed(8, BigNumber.ROUND_DOWN)); // 截断小数点后8位，并且去掉多余的0
                var addressOut = $('#ModalTransfer #input_addressOut').val();
                var remarks = $('#ModalTransfer #input_remarks').val();
                var nonce = parseInt($('#ModalTransfer #input_nonce').val());

                if (CheckTransfer(amount, addressOut, nonce, "", remarks)) {
                    var hash = Helper.SendTransferSubmit(e, "transfer", amount.toString(), addressOut, "", "", nonce, remarks);
                    Helper.Statusbar("statusbar", hash, "", "交易: " + addressOut + " 转出: " + Helper.Fix(amount), 1, nonceCur);
                    Helper.MessageBox('交易已提交');
                }
            }

        };

        function CheckTransfer(amount, addressOut, nonce, depend, remarks) {
            if (addressOut == "") {
                alert('addressOut Can not be empty');
                return false;
            }
            if (amount.isLessThanOrEqualTo(0)) {
                alert('amount Must be greater than zero');
                return false;
            }
            if (amount.isNaN()) {
                alert('amount Must be a number');
                return false;
            }
            if (isNaN(nonce)) {
                alert('nonce Must be a number');
                return false;
            }
            return true;
        }

        var transferIndex = 0;
        function onTransferInit() {

            $.ajax({
                url: Helper.GetServerIP() + "/GetTransfers",
                dataType: "text",
                type: "get",
                data: { address: addressCur, index: transferIndex, token: tokenAddress },
                success: function (data) {
                    colorindex = 1;
                    // 删除之前的数据
                    var mytableEle = document.getElementById("mytable");
                    for (var i = mytableEle.children.length - 1; i >= 0; i--) {
                        if (mytableEle.children[i].id.indexOf("_mytable111") == -1)
                            mytableEle.children[i].remove();
                    }

                    var jsonObj = JSON.parse(data);
                    if (jsonObj == null)
                        return;

                    for (var key in jsonObj) {

                        var hash = jsonObj[key]["hash"];

                        var color = colorlist[(colorindex - 1) % colorlist.length]; colorindex++;
                        var amount = GetAmountFormat(jsonObj[key]);

                        Helper.TableInsert2("mytable", hash, color, Helper.Simplify(hash, platform), amount)
                    }
                },
                error: function (err) {
                    alert("没有找到可用节点");
                }
            });
        }
        onTransferInit(0);

        function GetAmountFormat(jsonKey) {
            var amount = new BigNumber(jsonKey["amount"]).toFormat();

            if (jsonKey["type"] == "transfer") {
                if (jsonKey["addressIn"] == addressCur)
                    amount = "转账  -" + amount;
                else
                    amount = "+" + amount;
            }
            else {
                if (jsonKey["type"] == "Reward_Rule" || jsonKey["type"] == "Reward_Mc") {
                    amount = "出块  +" + amount;
                }
                else {
                    if (jsonKey["type"] == "contract") {
                        if (jsonKey["addressOut"] == "")
                            amount = "合约  发布";
                        else {
                            amount = "合约  调用";
                            try {
                                if (jsonKey["data"].indexOf("transfer(\"") != -1) {
                                    var array = jsonKey["data"].split("\"")
                                    amount = "转账 " + new BigNumber(array[3]).toFormat();
                                }
                            }
                            catch {

                            }
                        }
                    }
                }
            }
            return amount;
        }

        // WaitTable
        function onTransferWaitInit() {
            colorindex = 1;
            var count = Helper.GetTransferCount(addressCur + tokenAddress);
            for (var index = count; index >= 1; index--) {
                var str = Helper.LoadTransfer(addressCur + tokenAddress, index);
                var jsonObj = JSON.parse(str);
                if (jsonObj == null)
                    return;
                var hash = jsonObj["hash"];
                var color = colorlist[(colorindex - 1) % colorlist.length]; colorindex++;
                var amount = GetAmountFormat(jsonObj);
                Helper.TableInsert2("waittable", hash, color, Helper.Simplify(hash, platform), amount)
            }
        }
        onTransferWaitInit();

        function liOnclickUp(e) {
            transferIndex -= 20;
            if (transferIndex < 0)
                transferIndex = 0;
            onTransferInit();
        };
        function liOnclickDown(e) {
            var mytableEle = document.getElementById("mytable");
            if (mytableEle.children.length >= 22) {
                transferIndex += 20;
                onTransferInit();
            }
        };

        function liOnclick(e) {
            //alert(e.id);
            Helper.ShowTransfer(e.id)
        };

        function liOnModalQRCodeLeave(e) {
            $("#ModalQRCode").modal('hide');
        };

        function liOnShowQRCode(e) {
            $("#ModalQRCode").modal('show');

            // 删除之前的数据
            var myEle = document.getElementById("qrcode");
            for (var i = myEle.children.length - 1; i >= 0; i--) {
                myEle.children[i].remove();
            }

            //初始化存放二维码的div
            var qrcodeEncode = new QRCode(document.getElementById("qrcode"), {
                width: 300,
                height: 300
            });
            //window.location.href获取到URL
            qrcodeEncode.makeCode("http://www.SmartX.com/Wallet/transfer.html?target=" + addressCur);
        };

        function liOnScanQRCode(e) {
            $("#ModalScanQRCode").modal('show');
            $("#scan_addressIn").val(addressCur);
            $("#scan_addressOut").val("");
            $("#scan_amount").val("");
            $("#scan_nonce").val(nonceCur);
            document.getElementById('photo').style.display = "none";//不可见;
            document.getElementById('photo_image1').value = '';
            document.getElementById('photo_image2').value = '';
            document.getElementById('photo_image2').style.display = "block";//可见;
            $("#photo_image1").click();
        }

        var getObjectURL = function (file) {
            var url = null;
            if (window.createObjectURL != undefined) { // basic
                url = window.createObjectURL(file);
            } else if (window.URL != undefined) { // mozilla(firefox)
                url = window.URL.createObjectURL(file);
            } else if (window.webkitURL != undefined) { // webkit or chrome
                url = window.webkitURL.createObjectURL(file);
            }
            return url;
        }

        function OnScanQRCodeChange(e) {
            var file = document.getElementById(e).files[0];
            qrcode.decode(getObjectURL(file));
            qrcode.callback = function (imgMsg) {
                document.getElementById('photo').style.display = "none";//不可见;
                if (imgMsg == null || imgMsg == "error decoding QR Code") {
                    alert("无法识别,请重试！")
                    return;
                }
                document.getElementById('photo_image2').style.display = "none";//不可见;

                var search = imgMsg.split("?");
                if (search.length >= 2) {
                    var addressOut = getQueryVariable("target", "?" + search[1])
                    $("#scan_addressOut").val(addressOut);
                }
            }
        }

        function OnScanQRCodeSubmit(e) {
            var amount = new BigNumber($('#scan_amount').val());
            var addressOut = $('#scan_addressOut').val();
            var depend = $('#scan_depend').val();
            var remarks = $('#scan_remarks').val();
            var nonce = parseInt($('#scan_nonce').val());

            if (CheckTransfer(amount, addressOut, nonce, "", remarks)) {
                var hash = Helper.SendTransferSubmit(e, "transfer", amount.toString(), addressOut, "", "", nonce, remarks);
                Helper.Statusbar("statusbar", hash, "", "交易: " + addressOut + " 转出: " + Helper.Fix(amount), 1, nonceCur);
                Helper.MessageBox('交易已提交');
            }
        }

        function OnRefreshAmount() {
            $.ajax({
                url: Helper.GetServerIP() + "/balanceOf",
                dataType: "text",
                type: "get",
                data: { Address: addressCur, token: tokenAddress },
                success: function (data) {
                    var jsonObj = JSON.parse(data);
                    var amount = new BigNumber(jsonObj["amount"]).toFormat();
                    var nonce = parseInt(jsonObj["nonce"]);

                    var element = document.getElementById("address");
                    element.innerHTML = symbol + " : " + amount;
                    amountCur = amount;
                    nonceCur = nonce + 1;
                },
                error: function (err) {
                }
            });
            setTimeout(function () { OnRefreshAmount(); }, 5000);
        }
        OnRefreshAmount();

        function liOnSatswap() {
            window.location.href = "Satswap.html?address=" + addressCur + "&symbol=" + symbol + "&token=" + tokenAddress;
        };

        function onLockSubmit(e) {
            var lockTime = parseInt($('#ModalLock #input_LockTime').val());
            if (typeof (lockTime) != 'number'){
                alert("LockTime must be a Number");
                return;
            }

            var lockHeight = lockTime * 4 * 60;
            if (typeof (lockHeight) != 'number') {
                alert("LockTime must be a Number");
                return;
            }

            var input_nonce      = parseInt($('#ModalLock #input_nonce').val());
            var input_amount     = new BigNumber((new BigNumber($('#ModalLock #input_amount').val())).toFixed(8, BigNumber.ROUND_DOWN));
            var input_tokenA     = tokenAddress != "" ? tokenAddress : Helper.ERCSat();
            var input_LockName   = $('#ModalLock #input_LockName').val();
            var input_addressOut = $('#ModalLock #input_addressOut').val();

            if (input_LockName.indexOf(" ") != -1 || input_LockName.indexOf("   ") != -1) {
                alert("LockName No spaces or tabs are allowed");
                return;
            }

            if (CheckTransfer(input_amount, input_addressOut, input_nonce, "", input_LockName))
            {
                let addressOut = Helper.LockFactory();
                let data = Helper.StringFormat("approve(\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\")", input_addressOut, input_tokenA, input_amount, lockHeight, input_LockName);
                let depend = '';
                let remarks = '';

                console.log(addressCur + ' ' + data);

                var hash = Helper.SendTransferSubmit(null, "contract", '', addressOut, data, depend, input_nonce, remarks);

                $("#ModalLock").modal('hide');
                Helper.Statusbar("statusbar", hash, "", "发起锁仓: " + input_addressOut + " 序号: " + lockHeight, 1, input_nonce);

                Helper.MessageBox('发起锁仓已提交');
            }
        }

        Helper.Statusbar();


    </script>


</body>
</html>